var webpack = require("webpack");
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;

const path = require("path"),process = require("process");

var PATHS = {
  libsPath:path.resolve(process.cwd(),"./node_modules")
}


module.exports = {
  entry: {
    app:"./app/test/index.js",
   vendor: ["react","react-dom", "jquery","react-router","redux"],  // 330 */ 

  },
  output: {
    path: __dirname + "/build",
    filename: "bundle.js"
  },
  module: {
    loaders: [{
      test: /\.js?$/,
      exclude: /(node_modules|bower_components)/,
      loader: 'babel?presets[]=react,presets[]=es2015'
    }]
  },
  devServer: {
    hot: true,
    inline: true,
    host: "10.188.10.39", //10.188.10.39 localhost
    port: 8080,
    //其实很简单的，只要配置这个参数就可以了  55306ad76803fa53168b458b 555f1d3bcaa821e80e8b456a
    proxy: {
      /* '/api/*': {
              target: 'http://10.188.10.2:7500',
              secure: false,
              headers:{uid:"5579518dcaa8219c3a8b4568","ddd":"hhhhhhhhh"}
          },*/
      /* '/api/caigou/*': {
              target: 'http://10.188.10.2:7100',
              secure: false,
              headers:{uid:"55295ab9d2b57048348b456d","ddd":"hhhhhhhhh"}
          },*/
      /*  '/api/*': {
              target: 'http://10.188.10.2:7000',
              secure: false,
              headers:{uid:"55295ab9d2b57048348b456d","ddd":"hhhhhhhhh"}
          },*/
    }
  },
  resolve: {
    alias: {
      "jquery-calendar": "/app/common/form/jquery-calendar.js",
      'jquery':path.join(PATHS.libsPath,"/jquery/dist/jquery.min.js"),
      'react':path.join(PATHS.libsPath,"/react/dist/react.min.js"),
      'react-dom':path.join(PATHS.libsPath,"/react-dom/dist/react-dom.min.js"),       
      'JsBarcode':path.join(PATHS.libsPath,"/jsbarcode/dist/JsBarcode.all.min.js"),
      'reflux':path.join(PATHS.libsPath,"/reflux/dist/reflux.min.js"),
      'redux':path.join(PATHS.libsPath,"/redux/dist/redux.min.js"),
      'react-router':path.join(PATHS.libsPath,"/react-router/umd/ReactRouter.min.js"),
    }
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
   new CommonsChunkPlugin({
      name: "vendor",
      filename: "vendor.js",
      // filename: "vendor.js"
      // (Give the chunk a different name)
      minChunks: Infinity,
      // (with more entries, this ensures that no other module
      //  goes into the vendor chunk)
    }),
  ]

};
